package ren.kane.asdppp;

import ren.kane.asdppp.affiliation.Affiliation;
import ren.kane.asdppp.classification.PaymentClassification;
import ren.kane.asdppp.method.PaymentMethod;
import ren.kane.asdppp.schedule.PaymentSchedule;
import ren.kane.asdppp.transaction.pay.Paycheck;

import java.time.LocalDate;

/**
 * @author renrk(1275) on 2019-04-09 7:28 PM
 **/
public class Employee {

    private int empId;

    private String name;

    private String address;

    private PaymentClassification paymentClassification = null;

    private PaymentSchedule paymentSchedule = null;

    private PaymentMethod paymentMethod = null;

    private Affiliation affiliation = null;

    public Employee() {
    }

    public Employee(int empId, String name, String address) {
        this.empId = empId;
        this.name = name;
        this.address = address;
    }

    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public PaymentClassification getPaymentClassification() {
        return paymentClassification;
    }

    public void setPaymentClassification(PaymentClassification paymentClassification) {
        this.paymentClassification = paymentClassification;
    }

    public PaymentSchedule getPaymentSchedule() {
        return paymentSchedule;
    }

    public void setPaymentSchedule(PaymentSchedule paymentSchedule) {
        this.paymentSchedule = paymentSchedule;
    }

    public PaymentMethod getPaymentMethod() {
        return paymentMethod;
    }

    public void setPaymentMethod(PaymentMethod paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public Affiliation getAffiliation() {
        return affiliation;
    }

    public void setAffiliation(Affiliation affiliation) {
        this.affiliation = affiliation;
    }

    public boolean isPayDate(LocalDate payDate) {
        return paymentSchedule.isPayDate(payDate);
    }

    public LocalDate getPayPeriodStartDate(LocalDate payDate) {
        return paymentSchedule.getPayPeriodStartDate(payDate);
    }

    public void payday(Paycheck paycheck) {
        double grossPay = paymentClassification.calculatePay(paycheck);
        double deductions = affiliation.calculateDeductions(paycheck);
        double netPay = grossPay - deductions;
        paycheck.setGrossPay(grossPay);
        paycheck.setDeductions(deductions);
        paycheck.setNetPay(netPay);
        paymentMethod.pay(paycheck);
    }
}
